import os,sys

def read(file):
    file=open(file,"r")
    read=file.read()
    file.close()
    return read

class sink:
    name="Computer"
    files=[]
    def __init__(self,config):
        self.config=config
        self.cache_files=self.get_files()
    def get_files(self):
        files=[]
        for file in os.listdir(self.config['folder']):
            files.append({"title":file.split(".")[0],"format":file.split(".")[1],"content":read(os.path.join(self.config['folder'],file))})
        return files
    def remove(self,file):
        print "no removing in debug mode"
        return #os.remove(os.path.join(self.config['folder'],file['title']+"."+file['format'])
    def create(self,file):
        print "creating %s"%file['title']
        print os.path.join(self.config['folder'],file['title']+"."+file['format'])
        f=open(os.path.join(self.config['folder'],file['title']+"."+file['format']))
        f.write(file['content'])
        f.close()